﻿using System.Collections.Generic;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;

namespace TextListContentPipelineExtension
{
    /// <summary>
    /// This class is a mirror of TextListLib.TextList. It's a good idea to have a separate
    /// Content Pipeline version of your runtime classes rather than use the runtime version in
    /// both the Content Pipeline and the game itself. The reason for this is that you may want
    /// to add something in the future that doesn't apply to the runtime type (e.g. Texture2DContent)
    /// or that only exists in the Content Pipeline assemblies. This way you don't have to worry about
    /// that problem ever.
    /// </summary>
    public class TextListContent
    {
        /// <summary>
        /// The lines of text from a text file.
        /// </summary>
        public List<string> TextData;

        /// <summary>
        /// Our constructor.
        /// </summary>
        public TextListContent()
        {
            TextData = new List<string>();
        }

        /// <summary>
        /// Write out our content using the ContentWriter (which is derived from BinaryWriter but adds many nice XNA-specific bits).
        /// </summary>
        /// <param name="writer">The Content Pipeline-supplied ContentWriter.</param>
        public void Write(ContentWriter writer)
        {
            writer.Write(TextData.Count);
            for (int i = 0; i < TextData.Count; i++)
            {
                writer.Write(TextData[i]);
            }
        }
    }
}
